#pragma once

#include <string>
#include <fstream>
#include "mutex.h"
#include "xepdt.h"
using namespace std;
using namespace gloox;

class XEPDT_API CLog
{
public:
	CLog();
	virtual ~CLog();

	enum LogLevel
	{
		Warning,
		Error,
		Info
	};

	void log( CLog::LogLevel level, const char *fmt, ... );

	void log( CLog::LogLevel level, string& str ) { log(level, str.c_str()); }

	void CloseLog();

	void ShowLastError();

private:
	std::fstream	 m_file;		// log-file stream
	util::Mutex      m_Lock;		// lock for thread-safe access

	DWORD			 m_dwStartTime; // application start time 
};

XEPDT_API extern CLog debug;
